package com.gs.synedocket.adapter;

import android.content.Context;
import android.view.View;

import com.gs.synedocket.R;
import com.gs.synedocket.adapter.base.BaseAdapter;
import com.gs.synedocket.adapter.base.BaseViewHolder;
import com.gs.synedocket.db.entity.DocketPhoto;

import java.util.List;

public class PhotoAdapter extends BaseAdapter<DocketPhoto> {

    private boolean logDetail;

    public PhotoAdapter(Context context, List<DocketPhoto> list, int layoutId) {
        super(context, list, layoutId);
    }

    @Override
    public void convert(BaseViewHolder holder, DocketPhoto item, int position) {
        holder.setImageUrl(R.id.iv_photo, item.getPhoto(), v -> {
            if (onItemChildrenClickListener != null) {
                onItemChildrenClickListener.onItemChildrenClickListener(v, position);
            }
        });
        if (logDetail) {
            holder.setVisibility(R.id.iv_delete, View.GONE);
        } else {
            holder.setOnClickListener(R.id.iv_delete, v -> {
                if (onItemChildrenClickListener != null) {
                    onItemChildrenClickListener.onItemChildrenClickListener(v, position);
                }
            });
        }
    }

    public void setLogDetail(boolean logDetail) {
        this.logDetail = logDetail;
    }
}
